package com.ubireality.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.ubireality.module.player.User;
import com.ubireality.repository.UserRepository;
import com.ubireality.service.bizlogic.RequestBean;
import com.ubireality.service.bizlogic.ServletControl;
import com.ubireality.service.bizlogic.dao.UserDAO;

/**
 * Servlet implementation class LoggerServlet
 */
@WebServlet("/LoggerServlet")
public class LoggerServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	@Inject
	private ServletControl sc;
	@Inject
	private RequestBean a;//this is a session scope bean
	@Inject
	private UserRepository userRepository;
	public LoggerServlet() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String paraString=request.getParameter("test");
		switch (paraString) {
		case "1":
			sc.doit();
			System.out.println(a.getA());
			break;
		case "2":
			User getUser = userRepository.findById(1L);
			PrintWriter out = response.getWriter();

			out.println("Hello World "+ getUser.getName());
			break;

		default:
			break;
		}
		
	}

}
